home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / include / lib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-04  |  2.8 KB  |  76 lines

  1. /* lib.h: declarations for shared routines.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef LIB_H
  20. #define LIB_H
  21.  
  22. #include "types.h"
  23.  
  24. /* Return a fresh copy of S1 followed by S2, et al.  */
  25. extern string concat P2H(string s1, string s2);
  26. extern string concat3 P3H(string, string, string);
  27. extern string concat4 P4H(string, string, string, string);
  28. extern string concat5 P5H(string, string, string, string, string);
  29.  
  30.  
  31. /* A fresh copy of just S.  */
  32. extern string xstrdup P1H(string s);
  33.  
  34.  
  35. /* True if FILENAME1 and FILENAME2 are the same file.  If stat fails on
  36.    either name, returns false, with no error message.  */
  37. extern boolean same_file_p P2H(string filename1, string filename2);
  38.  
  39.  
  40. /* If NAME has a suffix, return a pointer to its first character (i.e.,
  41.    the one after the `.'); otherwise, return NULL.  */
  42. extern string find_suffix P1H(string name);
  43.  
  44. /* Return NAME with any suffix removed.  */
  45. extern string remove_suffix P1H(string name);
  46.  
  47. /* Return S with the suffix SUFFIX, removing any suffix already present.
  48.    For example, `make_suffix ("/foo/bar.baz", "karl")' returns
  49.    `/foo/bar.karl'.  Returns a string allocated with malloc.  */
  50. extern string make_suffix P2H(string s, string suffix);
  51.  
  52. /* Return NAME with STEM_PREFIX prepended to the stem. For example,
  53.    `make_prefix ("/foo/bar.baz", "x")' returns `/foo/xbar.baz'.
  54.    Returns a string allocated with malloc.  */
  55. extern string make_prefix P2H(string stem_prefix, string name);
  56.  
  57. /* If NAME has a suffix, simply return it; otherwise, return
  58.    `NAME.SUFFIX'.  */
  59. extern string extend_filename P2H(string name, string suffix);
  60.  
  61.  
  62. /* These call the corresponding function in the standard library, and
  63.    abort if those routines fail.  Also, `xrealloc' calls `xmalloc' if
  64.    OLD_ADDRESS is null.  */
  65. extern address xmalloc P1H(unsigned size);
  66. extern address xrealloc P2H(address old_address, unsigned new_size);
  67. extern address xcalloc P2H(unsigned nelem, unsigned elsize);
  68.  
  69. /* (Re)Allocate N items of type T using xmalloc/xrealloc.  */
  70. #define XTALLOC(n, t) (t *) xmalloc ((n) * sizeof (t))
  71. #define XTALLOC1(t) XTALLOC (1, t)
  72. #define XRETALLOC(addr, n, t) ((addr) = (t *) xrealloc (addr, (n) * sizeof(t)))
  73.  
  74. #endif /* not LIB_H */
  75.  
  76.